from django.forms import ModelForm
from Grupos.models import Grupo
from django.contrib.auth.models import User

class GruposForm(ModelForm):
	def __init__(self, user, *args, **kwargs):
		super(GruposForm, self).__init__(*args, **kwargs)
		self.fields['creador'].queryset = User.objects.filter(pk = user.id)
		self.fields['creador'].empty_label=None

	class Meta:
		model = Grupo

class GruposFormReadOnly(ModelForm):
	def __init__(self, user, *args, **kwargs):
		super(GruposFormReadOnly, self).__init__(*args, **kwargs)
		self.fields['creador'].queryset = User.objects.filter(pk = user.id)
		self.fields['creador'].empty_label=None
		self.fields['creador'].widget.attrs['readonly'] = True
		#self.fields['miembros'].queryset=User.objects.all().order_by('username')
		self.fields['miembros'].widget.attrs['readonly'] = True
		self.fields['nombre'].widget.attrs['readonly'] = True

	class Meta:
		model = Grupo